import { reactive, Ref, ref } from "vue"


export default class Controller{
	state:{ //state用于组织变量
		/**标题 */
		title:string,
	}

	/**弹窗ref */
	popup:Ref=ref(null) //state以外的变量用于额外的变量 如refs绑定

	constructor(){
		this.state = reactive({
			title:"Hello Uniapp Vue3.x Typescript Vite",
		})
	}

	/**打开弹窗 */
	public openPopup():void{ //public表示可以在外部调用
		this.popup.value?.open()
	}

	/**生成随机字符串 */
	private randomString(len:number):string{ //private表示只能在当前类中调用 外部看不到
		let $chars = 'ABCDEFGHJKMNPQRSTWXYZabcdefhijkmnprstwxyz2345678';
		let maxPos = $chars.length;
		let pwd = '';
		for (let i = 0; i < len; i++) {
			pwd += $chars.charAt(Math.floor(Math.random() * maxPos));
		}
		return pwd;
	}
}
